package private

import (
	"context"
	"fmt"
	"gitee.com/wanjimao/dongli-kit/pkg"
	"gitee.com/wanjimao/dongli-platform/tools"
	"gitee.com/wanjimao/dongli-util/dancetiktok"
	"gitee.com/wanjimao/dongli-util/dancetiktok/enums/dancetiktokenumsmymongo"
	"gitee.com/wanjimao/dongli-util/dancetiktok/enums/dancetiktokenumsmysql"
	"gitee.com/wanjimao/dongli-util/dancetiktok/funcs"
	"gitee.com/wanjimao/dongli-util/dancetiktok/model/dancetiktokmodelmongo"
	"gitee.com/wanjimao/dongli-util/dancetiktok/model/dancetiktokmodelmysql"
	"gitee.com/wanjimao/dongli-util/helper"
	"go.mongodb.org/mongo-driver/bson"
	"go.mongodb.org/mongo-driver/mongo"
	"go.uber.org/zap"
	"gorm.io/gorm"
	"time"

	pb "gitee.com/wanjimao/dongli-platform/api/gen/profile/api"
	"gitee.com/wanjimao/dongli-platform/services/profile/errors"
	"gitee.com/wanjimao/dongli-platform/services/profile/internal/db/redis"
)

func (s *Service) GetProfilePrivate(_ context.Context, request *pb.GetProfilePrivateRequest) (*pb.GetProfilePrivateResponse, error) {
	profiles := make([]*pb.Profile, 0)
	if request.GetUids() != nil {
		if ps, err := s.privateDao.GetProfiles(
			request.GetPlatformId(),
			request.GetChannelId(),
			request.GetUids().GetUid()...,
		); err != nil {
			s.logger.Error("privateDao GetProfiles err", zap.Error(err), zap.Any(
				"uids",
				request.GetUids().GetUid(),
			))
			return nil, errors.ErrGeneralFailure
		} else {
			profiles = append(profiles, ps...)
		}
	} else if request.GetName() != nil {
		page, pageSize := int64(1), int64(10)
		if request.GetName().GetIsRegexp() {
			if request.GetName().GetPage() > 1 {
				page = int64(request.GetName().GetPage())
			}
			if request.GetName().GetPageSize() > 0 {
				pageSize = int64(request.GetName().GetPageSize())
			}
		}
		if ps, err := s.privateDao.GetProfileByNickname(
			request.GetPlatformId(),
			request.GetChannelId(),
			request.GetName().GetName(),
			request.GetName().GetIsRegexp(),
			page,
			pageSize,
		); err != nil {
			s.logger.Error(
				"privateDao GetProfileByNickname err",
				zap.Error(err),
				zap.String("name", request.GetName().GetName()),
			)
			return nil, errors.ErrGeneralFailure
		} else {
			profiles = append(profiles, ps...)
		}
	} else if request.GetAll() != nil {
		if request.GetAll().Page < 1 || request.GetAll().PageSize < 1 {
			s.logger.Error("invalid page or page size", zap.Any("request", request))
			return nil, errors.ErrInvalidArgument
		}
		if ps, err := s.privateDao.GetAllProfiles(
			request.GetPlatformId(),
			request.GetChannelId(),
			int64(request.GetAll().Page),
			int64(request.GetAll().PageSize),
		); err != nil {
			s.logger.Error("privateDao GetProfiles err", zap.Error(err))
			return nil, errors.ErrGeneralFailure
		} else {
			profiles = append(profiles, ps...)
		}
	} else if request.GetAccount() != "" {
		if p, err := s.privateDao.GetProfilesByAccount(
			request.GetAccount(),
		); err != nil {
			s.logger.Error("privateDao GetProfileByAccount err", zap.Error(err))
			return nil, errors.ErrGeneralFailure
		} else {
			profiles = append(profiles, p)
		}
	} else {
		s.logger.Error("invalid request", zap.Any("request", request))
		return nil, errors.ErrInvalidArgument
	}

	uids := make([]string, 0)
	for _, v := range profiles {
		uids = append(uids, v.Uid)
	}

	if status := redis.GetProfileStatus(s.redisCli, uids...); len(status) > 0 {
		for _, v := range profiles {
			if st, ok := status[v.Uid]; ok {
				v.OnlineStatus = int32(st)
			}
		}
	}

	resp := &pb.GetProfilePrivateResponse{
		Profiles: profiles,
	}

	return resp, nil
}

func (s *Service) SetProfileStatus(_ context.Context, request *pb.SetProfileStatusRequest) (*pb.SetProfileStatusResponse, error) {
	if err := redis.SetProfileStatus(s.redisCli, request.Uid, int(request.Status)); err != nil {
		s.logger.Error("set profile status err", zap.Error(err))
		return nil, errors.ErrGeneralFailure
	}
	return &pb.SetProfileStatusResponse{}, nil
}

func (s *Service) GetProfileBasics(_ context.Context, request *pb.GetProfileBasicsRequest) (*pb.GetProfileBasicsResponse, error) {
	var uids []string
	if request.Uid == nil || len(request.GetUid()) <= 0 {
		s.logger.Error("get uid not found")
		return nil, errors.ErrNoMetaData
	} else {
		uids = request.Uid
	}
	basics, err := redis.GetBasicInfo(s.redisCli, uids...)
	if err != nil {
		s.logger.Error("get basic info error", zap.Error(err))
		return nil, errors.ErrGeneralFailure
	}
	if status := redis.GetProfileStatus(s.redisCli, uids...); len(status) > 0 {
		for _, basic := range basics {
			if v, ok := status[basic.Uid]; ok {
				basic.OnlineStatus = int32(v)
			}
		}
	}
	return &pb.GetProfileBasicsResponse{
		Basics: basics,
	}, nil
}

func (s *Service) ChannelJoin(_ context.Context, request *pb.ChannelJoinRequest) (*pb.ChannelJoinResponse, error) {
	logInfo := pkg.LogInfo{
		Method:     "RandName",
		TimeString: time.Now().Format(time.DateTime),
		TimeUnix:   time.Now().Unix(),
		UserId:     0,
		Req:        helper.InterfaceHelperObject.ToString(request),
		LogId:      request.LogId,
	}
	resp := &pb.ChannelJoinResponse{}

	channelTwoId := 0
	channelOneId := 0
	if channel, ok := tools.GlobalDataMapChannel[int32(request.Id)]; !ok {
		s.logger.Error(fmt.Sprintf("频道不存在 logInfo:%+v err:%+v", logInfo, nil))
		resp.ErrCode = dancetiktok.TheInputTextContainsIllegalCharacters
		return resp, errors.ErrLoadFailure
	} else {
		channelTwoId = int(channel.Catpid)
	}
	if channel, ok := tools.GlobalDataMapChannel[int32(channelTwoId)]; !ok {
		s.logger.Error(fmt.Sprintf("频道不存在 logInfo:%+v err:%+v", logInfo, nil))
		resp.ErrCode = dancetiktok.TheInputTextContainsIllegalCharacters
		return resp, errors.ErrLoadFailure
	} else {
		channelOneId = int(channel.Catpid)
	}
	//查询数量
	//查询用户信息
	//根据用户查询等级
	//Key2 := funcs.NewRedisTools(s.set.EnvServer, dancetiktokenumsredis.PlatformDanceMobile).GetDanceAccountRoleHashKey(string(request.RoleId))
	//f, err := s.redisCli.HMGet(context.Background(), Key2, dancetiktokenumsredis.DanceUserAccountRoleEnumsSex, dancetiktokenumsredis.DanceUserAccountRoleEnumsIsVop, dancetiktokenumsredis.DanceUserAccountRoleEnumsName, dancetiktokenumsredis.DanceUserAccountRoleEnumsAccountId).Result()
	//if nil != err && err != redis2.Nil {
	//	s.logger.Error(fmt.Sprintf("查询用户信息失败 logInfo:%+v err:%+v", logInfo, err))
	//	resp.ErrCode = dancetiktok.TheInputTextContainsIllegalCharacters
	//	return resp, errors.ErrLoadFailure
	//}
	//if len(f) == 2 || err == redis2.Nil {
	//	s.logger.Error(fmt.Sprintf("用户不存在 f:%+v logInfo:%+v err:%+v", f, logInfo, err))
	//	resp.ErrCode = dancetiktok.TheInputTextContainsIllegalCharacters
	//	return resp, errors.ErrLoadFailure
	//}
	//sex, _ := strconv.ParseInt(helper.InterfaceHelperObject.ToString(f[0]), 10, 64)
	//isVip, _ := strconv.ParseInt(helper.InterfaceHelperObject.ToString(f[1]), 10, 64)
	//name := helper.InterfaceHelperObject.ToString(f[2])
	//accountId, _ := strconv.ParseInt(helper.InterfaceHelperObject.ToString(f[3]), 10, 64)

	var accountRole2 dancetiktokmodelmysql.DanceUserAccountRole
	tx := s.mysqlDb.MysqlDanceDb.Model(&dancetiktokmodelmysql.DanceUserAccountRole{}).Where("id = ?", request.RoleId).First(&accountRole2)
	if nil != tx.Error && gorm.ErrRecordNotFound != tx.Error {
		s.logger.Error(fmt.Sprintf("查询角色异常 logInfo:%+v err:%+v", logInfo, tx.Error))
		resp.ErrCode = dancetiktok.CreateRoleRepeatRoleName
		return resp, nil
	}
	if accountRole2.AccountId == 0 {
		s.logger.Error(fmt.Sprintf("用户不存在 f:%+v logInfo:%+v err:%+v", nil, logInfo, nil))
		resp.ErrCode = dancetiktok.TheInputTextContainsIllegalCharacters
		return resp, errors.ErrLoadFailure
	}
	//是vip
	filter := bson.M{}
	filter["channel_three_id"] = request.Id
	collection := s.mongoDb.MongoDb.Database(fmt.Sprintf(dancetiktokenumsmymongo.DatabaseGame, s.set.EnvServer)).Collection(dancetiktokenumsmymongo.MongoDanceChannelRole)
	if number, err := collection.CountDocuments(context.TODO(), filter); nil != err && err != mongo.ErrNilDocument {
		s.logger.Error(fmt.Sprintf("查询数量异常 logInfo:%+v err:%+v", logInfo, err))
		resp.ErrCode = dancetiktok.TheInputTextContainsIllegalCharacters
		return resp, errors.ErrLoadFailure
	} else {
		if accountRole2.IsVip == 1 {
			if int32(number) >= tools.GlobalDataMapChannel[int32(request.Id)].Ordinary+tools.GlobalDataMapChannel[int32(request.Id)].Vip {
				s.logger.Error(fmt.Sprintf("查询数量异常 logInfo:%+v err:%+v", logInfo, err))
				resp.ErrCode = dancetiktok.TheChannelIsFull
				return resp, errors.ErrLoadFailure
			}
		} else {
			if int32(number) >= tools.GlobalDataMapChannel[int32(request.Id)].Ordinary {
				s.logger.Error(fmt.Sprintf("查询数量异常 logInfo:%+v err:%+v", logInfo, err))
				resp.ErrCode = dancetiktok.TheChannelIsFull
				return resp, errors.ErrLoadFailure
			}
		}
	}

	//删除
	filter = bson.M{}
	filter["role_id"] = request.Id
	if many, err := s.mongoDb.MongoDb.Database(fmt.Sprintf(dancetiktokenumsmymongo.DatabaseGame, s.set.EnvServer)).Collection(dancetiktokenumsmymongo.MongoDanceChannelRole).DeleteMany(context.TODO(), filter); err != nil {
		s.logger.Error(fmt.Sprintf("删除频道记录失败 logInfo:%+v err:%+v", logInfo, err))
		resp.ErrCode = dancetiktok.TheInputTextContainsIllegalCharacters
		return resp, errors.ErrLoadFailure
	} else {
		s.logger.Info(fmt.Sprintf("删除用户数据数量- %+v data:%+v", many.DeletedCount, many))
	}

	//查询用户信息
	logData := &dancetiktokmodelmongo.DanceChannelRole{
		Id_:             funcs.UniqueId(),
		ChannelOneId:    int64(channelOneId),
		ChannelTwoId:    int64(channelTwoId),
		ChannelThreeId:  int64(request.Id),
		IsVip:           int8(accountRole2.IsVip),
		AccountId:       accountRole2.AccountId,
		RoleId:          request.RoleId,
		Name:            accountRole2.Name,
		Sex:             int8(accountRole2.Sex),
		UpdatedAt:       time.Now().Unix(),
		CreatedAt:       time.Now().Unix(),
		CreatedAtString: time.Now().Format(time.DateTime),
	}
	//写入数据库
	collection = s.mongoDb.MongoDb.Database(fmt.Sprintf(dancetiktokenumsmymongo.DatabaseGame, s.set.EnvServer)).Collection(dancetiktokenumsmymongo.MongoDanceChannelRole)
	if profile, err := collection.InsertOne(context.TODO(), logData); nil != err {
		s.logger.Error(fmt.Sprintf("删除频道记录失败 logInfo:%+v err:%+v", logInfo, err))
		resp.ErrCode = dancetiktok.TheInputTextContainsIllegalCharacters
		return resp, errors.ErrLoadFailure
	} else {
		fmt.Println(fmt.Sprintf("BestFriends lr.statusDb.profile %+v", profile))
	}
	return &pb.ChannelJoinResponse{}, nil
}

func (s *Service) ItemUse(_ context.Context, request *pb.ItemUseRequest) (*pb.ItemUseResponse, error) {
	logInfo := pkg.LogInfo{
		Method:     "ItemUse",
		TimeString: time.Now().Format(time.DateTime),
		TimeUnix:   time.Now().Unix(),
		UserId:     0,
		Req:        helper.InterfaceHelperObject.ToString(request),
		LogId:      request.LogId,
	}
	resp := &pb.ItemUseResponse{}

	//根据散件id，查询散件详情
	var element dancetiktokmodelmysql.DanceElement
	tx := s.mysqlDb.MysqlDanceDb.Model(&dancetiktokmodelmysql.DanceElement{}).Where("id = ?", request.Id).First(&element)
	if nil != tx.Error && gorm.ErrRecordNotFound != tx.Error {
		s.logger.Error(fmt.Sprintf("查询角色异常 logInfo:%+v err:%+v", logInfo, tx.Error))
		resp.ErrCode = dancetiktok.CreateRoleRepeatRoleName
		return resp, nil
	}
	//根据编号查询类型
	if element.EleType != dancetiktokenumsmysql.DanceElementTypeProps {
		s.logger.Error(fmt.Sprintf("查询角色异常 logInfo:%+v err:%+v", logInfo, tx.Error))
		resp.ErrCode = dancetiktok.CreateRoleRepeatRoleName
		return resp, nil
	}

	//背包查询
	var bag dancetiktokmodelmysql.DanceBag
	tx = s.mysqlDb.MysqlDanceDb.Model(&dancetiktokmodelmysql.DanceBag{}).Where("id = ?", request.Id).First(&bag)
	if nil != tx.Error && gorm.ErrRecordNotFound != tx.Error {
		s.logger.Error(fmt.Sprintf("查询角色异常 logInfo:%+v err:%+v", logInfo, tx.Error))
		resp.ErrCode = dancetiktok.CreateRoleRepeatRoleName
		return resp, nil
	}
	if bag.Number < 1 {
		return resp, nil
	}

	var bagDetail dancetiktokmodelmysql.DanceBagDetail
	tx = s.mysqlDb.MysqlDanceDb.Model(&dancetiktokmodelmysql.DanceBagDetail{}).Where("pid = ?", bag.Id).First(&bagDetail)
	if nil != tx.Error && gorm.ErrRecordNotFound != tx.Error {
		s.logger.Error(fmt.Sprintf("查询角色异常 logInfo:%+v err:%+v", logInfo, tx.Error))
		resp.ErrCode = dancetiktok.CreateRoleRepeatRoleName
		return resp, nil
	}

	//根据编号查询类型
	if element.EleType != dancetiktokenumsmysql.DanceElementTypeProps {
		s.logger.Error(fmt.Sprintf("查询角色异常 logInfo:%+v err:%+v", logInfo, tx.Error))
		resp.ErrCode = dancetiktok.CreateRoleRepeatRoleName
		return resp, nil
	}

	if _, ok := tools.GlobalDataMapItemRule[helper.InterfaceHelperObject.ToString(element.EleType)+"和"+helper.InterfaceHelperObject.ToString(element.ElePart)]; !ok {
		s.logger.Error(fmt.Sprintf("类型不存在 logInfo:%+v err:%+v", logInfo, nil))
		resp.ErrCode = dancetiktok.TheInputTextContainsIllegalCharacters
		return resp, errors.ErrLoadFailure
	} else {
		//channelTwoId = int(channel.Catpid)
	}

	begin := s.mysqlDb.MysqlDanceDb.Begin()
	if begin.Error != nil {
		s.logger.Error(fmt.Sprintf("开启事务失败 logInfo:%+v err:%+v", logInfo, nil))
		resp.ErrCode = dancetiktok.TheInputTextContainsIllegalCharacters
		return resp, errors.ErrLoadFailure
	}
	if create := begin.Model(&dancetiktokmodelmysql.DanceBag{}).
		Where("role_id = ?", request.RoleId).
		Where("no = ?", request.Id).
		Where("number >= ?", request.Id).
		UpdateColumn("number ", gorm.Expr("number  - ?", 1)); nil != create.Error && create.Error != gorm.ErrRecordNotFound {
		begin.Rollback()
		s.logger.Error(fmt.Sprintf("减少数据失败 logInfo:%+v err:%+v", logInfo, nil))
		resp.ErrCode = dancetiktok.TheInputTextContainsIllegalCharacters
		return resp, errors.ErrLoadFailure
	}

	if tx = begin.Unscoped().Where("id = ?", bagDetail.Id).Delete(&dancetiktokmodelmysql.DanceBagDetail{}); nil != tx.Error && tx.Error != gorm.ErrRecordNotFound {
		begin.Rollback()
		s.logger.Error(fmt.Sprintf("删除数据数据失败 logInfo:%+v err:%+v", logInfo, nil))
		resp.ErrCode = dancetiktok.TheInputTextContainsIllegalCharacters
		return resp, errors.ErrLoadFailure
	}
	if resCommit := begin.Commit(); nil != resCommit.Error {
		begin.Rollback()
		s.logger.Error(fmt.Sprintf("提交事务数据失败 logInfo:%+v err:%+v", logInfo, nil))
		resp.ErrCode = dancetiktok.TheInputTextContainsIllegalCharacters
		return resp, errors.ErrLoadFailure
	}
	return &pb.ItemUseResponse{}, nil
}

func (s *Service) ItemFashionChange(_ context.Context, request *pb.ItemFashionChangeRequest) (*pb.ItemFashionChangeResponse, error) {
	logInfo := pkg.LogInfo{
		Method:     "RandName",
		TimeString: time.Now().Format(time.DateTime),
		TimeUnix:   time.Now().Unix(),
		UserId:     0,
		Req:        helper.InterfaceHelperObject.ToString(request),
		LogId:      request.LogId,
	}
	resp := &pb.ItemFashionChangeResponse{}
	fmt.Println(logInfo)
	return resp, nil
}

func (s *Service) ItemFashionUnload(_ context.Context, request *pb.ItemFashionUnloadRequest) (*pb.ItemFashionUnloadResponse, error) {
	logInfo := pkg.LogInfo{
		Method:     "RandName",
		TimeString: time.Now().Format(time.DateTime),
		TimeUnix:   time.Now().Unix(),
		UserId:     0,
		Req:        helper.InterfaceHelperObject.ToString(request),
		LogId:      request.LogId,
	}
	resp := &pb.ItemFashionUnloadResponse{}
	fmt.Println(logInfo)
	return resp, nil
}

func (s *Service) PlayerPropNotify(_ context.Context, request *pb.PlayerPropNotifyRequest) (*pb.PlayerPropNotifyResponse, error) {
	logInfo := pkg.LogInfo{
		Method:     "RandName",
		TimeString: time.Now().Format(time.DateTime),
		TimeUnix:   time.Now().Unix(),
		UserId:     0,
		Req:        helper.InterfaceHelperObject.ToString(request),
		LogId:      request.LogId,
	}
	resp := &pb.PlayerPropNotifyResponse{}
	//查询用户角色数据
	//用户
	var accountRole dancetiktokmodelmysql.DanceUserAccountRole
	tx := s.mysqlDb.MysqlDanceDb.Model(&dancetiktokmodelmysql.DanceUserAccountRole{}).Where("id = ?", request.RoleId).First(&accountRole)
	if nil != tx.Error && gorm.ErrRecordNotFound != tx.Error {
		s.logger.Error(fmt.Sprintf("查询角色异常 logInfo:%+v err:%+v", logInfo, tx.Error))
		resp.ErrCode = dancetiktok.ErrorLoginDataException
		return resp, errors.ErrLoadFailure
	}
	if accountRole.Id == 0 || accountRole.AccountId == 0 {
		s.logger.Error(fmt.Sprintf("取出的数据异常 logInfo:%+v err:%+v", logInfo, tx.Error))
		resp.ErrCode = dancetiktok.ErrorLoginDataException
		return resp, errors.ErrNotFound
	}

	resp.ListIntProperty = make([]*pb.IKeyIValue, 0)

	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyCurExp,
		Value: int32(accountRole.CurExp),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyLevel,
		Value: int32(accountRole.Level),
	})

	//用户当前所在的频道id
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyChannel,
		Value: int32(request.ChannelId),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyBirthday,
		Value: int32(accountRole.Birthday),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyMarried,
		Value: int32(accountRole.Married),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyLoverId,
		Value: int32(accountRole.LoverId),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyPraise,
		Value: int32(accountRole.Praise),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyLoverLevel,
		Value: int32(0),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyLoverExp,
		Value: int32(0),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyVipLevel,
		Value: int32(accountRole.VipLevel),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyHair,
		Value: int32(accountRole.Head),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyFace,
		Value: int32(accountRole.Face),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyUpper,
		Value: int32(accountRole.Coat),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyLower,
		Value: int32(accountRole.Bottom),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyShoes,
		Value: int32(accountRole.Shoe),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertySuit1,
		Value: int32(accountRole.Suit1),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertySuit2,
		Value: int32(accountRole.Suit2),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyHandheld,
		Value: int32(accountRole.Handheld),
	})

	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyBackAccessory,
		Value: int32(accountRole.BackAccessory),
	})

	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyBase,
		Value: int32(accountRole.Base),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyDJBooth,
		Value: int32(accountRole.DJBooth),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyTitle,
		Value: int32(accountRole.Title),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyNicknameEffect,
		Value: int32(accountRole.NicknameEffect),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyBadge1,
		Value: int32(accountRole.Badge1),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyBadge2,
		Value: int32(accountRole.Badge2),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyBadge3,
		Value: int32(accountRole.Badge3),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyBadge4,
		Value: int32(accountRole.Badge4),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyBadge5,
		Value: int32(accountRole.Badge5),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyBadge6,
		Value: int32(accountRole.Badge6),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyRing,
		Value: int32(accountRole.Ring),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyAvatarFrame,
		Value: int32(accountRole.AvatarFrame),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyScoreBackgroundCard,
		Value: int32(accountRole.ScoreBackgroundCard),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyDynamicBackgroundCard,
		Value: int32(accountRole.DynamicBackgroundCard),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyCoupleRing,
		Value: int32(accountRole.CoupleRing),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyCoupleInformationCard,
		Value: int32(accountRole.CoupleInformationCard),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyCoupleRegistrationCertificate,
		Value: int32(accountRole.CoupleRegistrationCertificate),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyDiamond,
		Value: int32(accountRole.Diamond),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyDiamondBind,
		Value: int32(accountRole.DiamondBind),
	})
	resp.ListIntProperty = append(resp.ListIntProperty, &pb.IKeyIValue{
		Key:   dancetiktokenumsmysql.CommonPropertyGold,
		Value: int32(accountRole.Gold),
	})

	fmt.Println(logInfo)
	return resp, nil
}
